import { Entity, ManyToOne } from 'typeorm';

import { BaseCartsEntity } from './baseCarts.entity';
import { UserEntity } from '@/modules/User/entities';
import { GoodEntity } from './good.entity';

@Entity('carts')
export class CartsEntity extends BaseCartsEntity {
  @ManyToOne((type) => UserEntity, (user: UserEntity) => user.carts, {
    onDelete: 'CASCADE',
  })
  user: UserEntity;

  @ManyToOne((type) => GoodEntity, (goods) => goods.carts, {
    onDelete: 'CASCADE',
  })
  good: GoodEntity;
}
